#ifndef WEATHER_H
#define WEATHER_H

#include <QWidget>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QJsonDocument>
#include <QJsonValue>
#include <QJsonObject>
#include <QJsonArray>
#include <QVector>
#include <QFile>
#include <QTextStream>
#include <QStringList>
#include <QRegularExpression>
#include "qmydatabase.h"
#include <QListWidget>

namespace Ui {
class weather;
}

struct cityinfo{
    QString city;
    QString citykey;
    QString parent;
    QString updatetime;
};

struct airindex{
    QString shidu;
    qlonglong pm25;
    qlonglong pm10;
    QString quality;
    QString wendu;
    QString warn;
};

struct forecast{
    QString date;
    QString high;
    QString low;
    QString ymd;
    QString week;
    QString sunrise;
    QString sunset;
    qlonglong aqi;
    QString fx;
    QString fl;
    QString type;
    QString notice;
};

class weather : public QWidget
{
    Q_OBJECT

public:
    explicit weather(QWidget *parent = nullptr);
    ~weather();

public:
    void parsejson(QByteArray & byteArr);
    QString findCityid( QString *str);
    QString conversion(QString * str);
    QString airpollution(qlonglong  num);

private slots:
    void finishedSlot(QNetworkReply * reply);

    void weathershowSlot();

    void on_pushButton_clicked();

    void on_comboBox_currentTextChanged(const QString &arg1);

    void on_pushButton_2_clicked();

    void comboxshow();

    // void on_lineEdit_textChanged(const QString &arg1);

private:
    Ui::weather *ui;
    QNetworkAccessManager * Manager;//声明一个网络管理者
    QVector<forecast>  * vFore;
    MyDatabase * cityDatabase;
    cityinfo ct;
    airindex air;
    // void comboxshow();
signals:
    void finishedparse();
    void finishedfollow();
};

#endif // WEATHER_H
